package kara;

import java.io.*;

public class A107 {
    static BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
    static int[] h, ne, e;
    static int idx = 1;  // 从0开始索引
    static int[] vis;
    static int n, m, source, destination;

    static void add(int a, int b) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx++;
    }

    static boolean dfs(int current, int end) {
        if (current == end) return true;
        for (int i = h[current]; i != 0; i = ne[i]) {
            int next = e[i];
            if (vis[next] == 0) {
                vis[next] = 1;
                if (dfs(next, end)) return true;
                vis[next] = 0;  // 回溯
            }
        }
        return false;
    }

    public static void main(String[] args) throws IOException {
        String[] s = read.readLine().split(" ");
        n = Integer.parseInt(s[0]);
        m = Integer.parseInt(s[1]);

        h = new int[n + 1];
        e = new int[2 * m + 5];  // 足够容量
        ne = new int[2 * m + 5];
        vis = new int[n + 1];

        for (int i = 0; i < m; i++) {
            String[] str = read.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            add(a, b);
            add(b, a);  // 无向图需双向添加
        }

        String[] s1 = read.readLine().split(" ");
        source = Integer.parseInt(s1[0]);
        destination = Integer.parseInt(s1[1]);

        vis[source] = 1;
        System.out.println(dfs(source, destination) ? 1 : 0);
    }
}